#!/bin/bash
export PATH=/bin:/usr/bin:/usr/externals/bin:/usr/sbin:/usr/local/bin:/usr/lib64/qt-3.3/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/bin:/usr/externals/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/usr/local/bin:/sbin:/usr/sbin:/usr/bin:/usr/java/latest/bin:/opt/puppetlabs/bin:/root/bin:/usr/java/latest/bin
users=`lid -g pku|awk -F'(' '{print $1}'`
echo class pku::accounts {
for user in $users
do
    uid=`id -u $user`
    groups=`id -G $user`
    groups=${groups//290/1290}
    shell=`getent passwd $user | cut -d: -f7`


        echo "  user { '$user':"
        echo "    ensure       => 'present',"
        echo "    comment      => '$user',"
        echo "    gid          => '1020',"
        echo "    home         => '/home/pku/$user',"
        echo "    managehome   => true,"
        echo "    shell        => '$shell',"
        echo "    uid          => '$uid',"
        echo "  }"
done
        echo "  group { 'pku':"
        echo "    ensure  => 'present',"
        echo "    gid     => '1020',"
        echo "  }"
        echo "}"
